package com.cy.pj.goods.dao;

import com.cy.pj.goods.pojo.Goods;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class GoodsDaoImpl implements GoodsDao{
    @Autowired
    private SqlSession sqlSession;

    @Override
    public List<Goods> findGoods() throws IOException {
        System.out.println("你好");
        return sqlSession.selectList("com.cy.pj.goods.dao.GoodsDao.findGoods");
    }

    @Override
    public int deleteById(Integer Id) {
        return 0;
    }

    @Override
    public int deleteObjects(Integer... ids) {
        String statement="com.cy.pj.goods.dao.GoodsDao.deleteObjects";
        Map<String,Object> map=new HashMap<>();
        map.put("ids", ids);
        //return sqlSession.delete(statement, ids);//不允许直接这样传值
        //一般有多个参数或者是可变参数时，这个参数要封装到map进行传递
        return sqlSession.delete(statement,map);
    }
}
